<?php

	$db_host = 'localhost';
	 $db_user = 'function';
	 $db_pwd = 'w9ak4X1l0Y';

	 $database = 'function_a5110060';

	 $table = 'Sub_Location_Master';

	$con = mysql_connect($db_host, $db_user, $db_pwd);
	if (!$con)
	die("Can't connect to database");
	mysql_select_db($database,$con);

	$subLocation = $_REQUEST['sublocation'];
	$subLocationId = $_REQUEST['sublocationId'];
	$masterLocationId = $_REQUEST['location_dd'];
	$currentDate = date("Y-m-d");

	//echo $subLocation." ".$masterLocationId;

	if (empty($subLocationId)) { 
	$sql="INSERT INTO {$table} (master_location_id,sub_location_name,created_date,modified_date) VALUES ('".$masterLocationId."','".$subLocation."','".$currentDate."','".$currentDate."')";
	//echo("Sql :".$sql);
	$result=mysql_query($sql);
	} else {
		$sql="UPDATE {$table} SET sub_location_name='".$subLocation."', master_location_id='".$masterLocationId."',modified_date='".$currentDate."' where sub_location_id=".$subLocationId;
		//echo("Sql :".$sql);
		$result=mysql_query($sql);
		//echo("$result :".$result);
	}
	header("Location: ../subLocation.php");
?> 